﻿using BizModels;
using DataModel;
using IRepositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Repositories
{
    public class CategoryRepository : RepositoryBase, ICategoryRepository
    {
        public CategoryRepository()
        {
            Context = new HinokyEntities();
        }

        public List<CategoryT> GetTotalCategoryList()
        {
            var data = Context.Categories.OrderByDescending(s => s.OrderNum).Where(s => s.Board.Count > 0).Select(s => new CategoryT
            {
                CategoryName = s.CategoryName,
                ArticleCount = s.Board.Count
            }).ToList();

            return data;
        }
    }
}
